package com.jacen.fzxs.service.impl;

import java.sql.SQLException;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.jacen.fzxs.dao.IBaseDao;
import com.jacen.fzxs.dao.IRoleDao;
import com.jacen.fzxs.entity.RoleEntity;
import com.jacen.fzxs.service.IRoleService;
import com.jacen.fzxs.web.Pager;

/**
 * 
 * @author Jacen
 *
 */
@Service
@Transactional(rollbackFor = Exception.class)
public class RoleService extends BaseService<RoleEntity> implements IRoleService {
	
	@Resource
	private IRoleDao roleDao;
	
	@Override
	public IBaseDao<RoleEntity> getDao() {
		// TODO Auto-generated method stub
		return roleDao;
	}

	@Override
	@Transactional(readOnly = true)
	public List<RoleEntity> getPage(Pager pager, Map<String, String> params) throws SQLException {
		pager.setTotalCount(getCount(params));
		return roleDao.getPage((pager.getCurPageNum()-1) * pager.getPageSize() , pager.getPageSize(), params);
	}
	
	@Transactional(readOnly = true)
	public int getCount(Map<String, ? extends Object> params) throws SQLException {
		return roleDao.getCount(params);
	}

}
